package com.dtsheep.elasticsearch.es.client.document;

import com.dtsheep.elasticsearch.es.client.ElasticsearchClientUtil;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * DeleteDocument
 *
 * <p>
 *     删除文档
 * </p>
 *
 * @author chuanbai
 * @date 2024/5/24
 */
public class DeleteDocument {

    public static void main(String[] args) throws IOException {

        RestHighLevelClient client = ElasticsearchClientUtil.getEsClient();

        DeleteResponse response = client
                .delete(new DeleteRequest()
                        .index("user")
                        .id("1"), RequestOptions.DEFAULT);
        System.out.println(response.getResult());
    }
}
